home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / incrementalSaveProcessPath.m < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.9 KB  |  101 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  November 12 2000
  22. //
  23. //  Procedure Name:
  24. //      incrementalSaveProcessPath
  25. //
  26. //  Description:
  27. //      Takes the save file path and returns the information that we'll need 
  28. //        to do the incremental save.
  29. //
  30. //  Input Arguments:
  31. //      path to split
  32. //
  33. //  Return Value:
  34. //      String array where elements are as follows:
  35. //            0 - scene name
  36. //            1 - scene path
  37. //            2 - scene name extension
  38. //            3 - scene prefix
  39. //            4 - version string
  40. //            5 - increment dir name
  41. //
  42. global proc string[] incrementalSaveProcessPath( string $scenePath )
  43. {
  44.     string $result[];
  45.  
  46.     // Separate the full filename into path and name (eg. "C:/maya/projects/scenes/" and "myScene.mb")
  47.     //
  48.     string $scenePath = `file -q -sceneName`;
  49.     string $sceneName = `match "[^/]+$" $scenePath`;
  50.     $scenePath = `substring $scenePath 1 (size($scenePath) - size($sceneName))`;
  51.  
  52.     string $sceneExtension = `match "[.][^.]*$" $sceneName`;
  53.     if($sceneExtension == `match "[.][0-9]+" $sceneExtension`) {
  54.         $sceneExtension = "";
  55.     } 
  56.  
  57.     string $fullScenePrefix = `substring $sceneName 1 (size($sceneName) - size($sceneExtension))`;
  58.  
  59.     string $currVersionString = `match "[.][0-9]+$" $fullScenePrefix`;
  60.     $currVersionString = `match "[0-9]+" $currVersionString`;
  61.  
  62.     // Find the extension and "prefix" of the sceneName. We may use the "fullScenePrefix" later.
  63.     // For example, we would want "myScene4.screen2.0001.mb" to give us "myScene4.screen2"
  64.     //
  65.     string $sceneNamePrefix = $fullScenePrefix;
  66.  
  67.     if($currVersionString != "") {
  68.         $sceneNamePrefix = `substring $sceneNamePrefix 1 
  69.             (size($sceneNamePrefix) - size($currVersionString) - 1)`;
  70.     }
  71.  
  72.     string $incrementDirName = "incrementalSave/" + $sceneNamePrefix + $sceneExtension + "/";
  73.     string $lastDirectoryName = `match "incrementalSave/[^/]+/$" $scenePath`;
  74.  
  75.     if($lastDirectoryName == $incrementDirName) {
  76.         // The directory-name for storing older increments is already at the end of the
  77.         // path for the current scene, so we can assume that the user is saving changes to
  78.         // an older increment. We will want to save these changes to the original scene name.
  79.         //
  80.         $scenePath = `substring $scenePath 1 (size($scenePath) - size($lastDirectoryName))`;
  81.     } else {
  82.         // There is the possibility of users naming a scene so that it ends in
  83.         // a number (myOriginalScene.4.ma), just like increments are.
  84.         // If this happens, the previous code will have been fooled into thinking that
  85.         // the number was not part of the scene name. However, if we know that we're
  86.         // not inside the increments directory, then we know that the full original 
  87.         // scene prefix should be used (not the one with the number trimmed off!).
  88.         //
  89.         $sceneNamePrefix = $fullScenePrefix;
  90.         $incrementDirName = "incrementalSave/" + $sceneNamePrefix + $sceneExtension;
  91.     }
  92.  
  93.     $result[0] = $scenePath;
  94.     $result[1] = $sceneName;
  95.     $result[2] = $sceneExtension;
  96.     $result[3] = $sceneNamePrefix;
  97.     $result[4] = $currVersionString;
  98.     $result[5] = $incrementDirName;
  99.  
  100.     return $result;
  101. }